#include "MyWidget.h"
#include "OpenGLDemo.h"

MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
{
    resize(800, 600);

    m_menuButtonLayout = new QVBoxLayout;
    m_menuButtonLayout->setAlignment(Qt::AlignTop);
    m_menuTitle = new QLabel(this);
    m_menuTitle->setText("Menu");
    m_menuTitle->setAlignment(Qt::AlignCenter);

    m_openGLDemoButton = new QPushButton("OpenGL Sample", this);
    m_openGLDemoButton->setFixedSize(140, 30);

    m_menuButtonLayout->addWidget(m_menuTitle);
    m_menuButtonLayout->addWidget(m_openGLDemoButton);
    m_menuWidget = new QWidget(this);
    m_menuWidget->setLayout(m_menuButtonLayout);

    QFrame* line = new QFrame(this);
    line->setFrameShape(QFrame::VLine);
    line->setFrameShadow(QFrame::Sunken);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(m_menuWidget, 1);
    mainLayout->addWidget(line);  

    setLayout(mainLayout);
    connect(m_openGLDemoButton, &QPushButton::clicked, this, &MyWidget::ShowOpenGLDemo);
}

void MyWidget::ShowOpenGLDemo()
{
    OpenGLDemoShow();
    return;
}
